#pragma strict
class Player extends Character{
	var Difficulty = "Default";
	public static var stamina: double = 100.0;
	var count = 0;
	var posX = 0;
	var posZ = 0;
	
	//variables for weapons
	var pistolAmmo: int = 0;		//amo type pistol
	var pMax: int = 40;
	var sniperAmmo: int = 0;		//amo type sniper		
	var sMax: int = 20;
	var assaultAmmo: int = 0;	//amo type assult
	var aMax: int = 120;
	var lmgAmmo: int = 0;		//amo type lmg
	var lmgMax: int = 120;
	

	public var weapons = new Weapon[2];

	
	function Start () {
		weapons[0] = new Pistol();
		weapons[1] = new SMG();
	}

	function Update () {
		//print(stamina);
		if(stamina < 100){
			stamina *= 1.001;
		}
		
		if(count >=100){
			count =0;
			posX = transform.position.x;
			posZ = transform.position.z;
		
		}
		count++;
	}
	
	function ammoUpdate(typeAmo: String, nAmo: int){
		/**tAmo is the type of ammunition
	* nAmo is the ammount of ammo:
	*		call with positive numbers for pickups
	*		negative numbers for firing
	* Also makes sure the ammo counts never exceed the max or drop below zeo
	*/
		//Emil, implementing the structure we talked about in class....
		
		if(typeAmo.Equals("pistol")){
			pistolAmmo += nAmo;
			if(pistolAmmo < 0 ){
				pistolAmmo = 0;
			}
			else if(pistolAmmo >= pMax){
				pistolAmmo = pMax;
			}
		}
	}
	function getWeapon(num: int): Weapon{
		return weapons[num];
	}
	/**
	*Simply swaps the weapons in the weapons array, moving index 0 to index 1 and index 1 to index 0
	*/
	function switchWeapon(){
		var tempWeapon:Weapon = weapons[0];
		weapons[0] = weapons[1];
		weapons[1] = tempWeapon;
		print("Slot 1: " + weapons[0].toString());
		print("Slot 2: " + weapons[1].toString());
	}
}